home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / program / wkmc.lha / wkmc / src / ppmview.c < prev    next >
C/C++ Source or Header  |  1995-10-23  |  2KB  |  93 lines

  1. /* PPMView v0.3 (23 October 1995) - ©1995 by WK-Artworks */
  2. /*
  3.  
  4.  wkmc is a simple true-color-display using a 8-bit-screen,
  5.  the idea behind this came from Stefan Kost and Smack/IFT
  6.  
  7.  NOTE: I think it's fast beeing pure C !
  8.  
  9.  
  10.  Advantages (compared against MultiColor):
  11.   -terrible high speed
  12.   -picture-size and -aspect isn't changed
  13.   -no ugly diagonal-dithering
  14.   -no flickering (uses Multiscan)
  15.   -uses all 256 registers (not only 255)
  16.   -every color-channel (RGB) has a diffent number of
  17.    shades ("eye-sensitive")
  18. */
  19.  
  20. #include "wkmc.h"
  21.  
  22. int main(int argc,char **argv) {
  23.  FILE *fh;
  24.  char hs[64];
  25.  UBYTE *bl[8];
  26.  int width,height,i,qt=0,bn;
  27.  UBYTE *line=NULL;
  28.  struct IntuiMessage *imsg;
  29.  ULONG iclass;
  30.  USHORT icode;
  31.  printf("\n PPMView v0.3 - ©1995 by WK-Artworks\n");
  32.  printf("-------------------------------------\n");
  33.  if(argc<2) {printf(" Usage: ppmview <ppm-file>\n");return(1);}
  34.  fh=fopen(argv[1],"rb");
  35.  if(fh==NULL) return(1);
  36.  fscanf(fh,"%s",hs);
  37.  
  38.  fscanf(fh,"%s",hs);
  39.  width=strtol(hs,NULL,10);
  40.  fscanf(fh,"%s",hs);
  41.  height=strtol(hs,NULL,10);
  42.  fscanf(fh,"%s",hs);
  43.  #ifdef __GNUC__
  44.  fread(&i,1,1,fh);
  45.  #endif
  46.  printf(" Resolution : %dx%d\n",width,height);
  47.  if(init(width,height)==0) {
  48.  
  49.   /* do it */
  50.   bn=theScreen->BitMap.BytesPerRow;
  51.  
  52.   for(i=0;i<8;i++) {bl[i]=malloc(bn);if(bl[i]==NULL) return(1);}
  53.   line=(UBYTE*)malloc(3*width);
  54.   if(line==NULL) {fclose(fh);return(1);}
  55.   time(&tm1);
  56.   for(i=0;i<height;i++) {
  57.    fread(line,1,3*width,fh);   
  58.    SetLineS(i,line,width,bn,bl); 
  59.   }
  60.  
  61.   time(&tm2);
  62.   tm=difftime(tm2,tm1);
  63.   printf(" Decode-time: %lds\n",(ULONG)tm);
  64.   free(line);
  65.   for(i=0;i<8;i++) free(bl[i]);
  66.   fclose(fh);
  67.  
  68.   /* wait */
  69.   do {
  70.    WaitPort(theWindow->UserPort);
  71.    do {
  72.     imsg=(struct IntuiMessage*)GetMsg(theWindow->UserPort);
  73.     if(imsg!=NULL) {
  74.      iclass=imsg->Class;
  75.      icode=imsg->Code;
  76.      ReplyMsg((struct Message*)imsg);
  77.      switch(iclass) {
  78.       case IDCMP_VANILLAKEY:switch(icode) {
  79.                              case ' ':qt=1;break;
  80.                             }
  81.      }
  82.     }
  83.    } while(imsg!=NULL);
  84.   } while(qt==0);
  85.   /* clean up*/
  86.   cleanup();
  87.  }
  88.  return(0);
  89.  printf("\n");
  90. }
  91.  
  92.  
  93.